package seqlist.leetcode;

import java.util.LinkedList;
import java.util.Queue;

public class Num225jinjie {
    private Queue<Integer> queue = new LinkedList<>();
    public void push(int x){
        //记录长度
        int size = queue.size();
        //新元素直接入队列
        queue.offer(x);
        //将之前记录的元素依次出队再入队，新元素就变成了队首元素
        for (int i = 0; i < size; i++) {
            queue.offer(queue.poll());
        }
    }
    public int pop() {
        return queue.poll();
    }

    public int top() {
        return queue.peek();
    }

    public boolean empty() {
        return queue.isEmpty();
    }
}
